<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2021/5/6
  Time: 17:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/common/common.jsp" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript">

        function getTree() {

            var tree = [];

            $.ajax({
                dataType: "json",
                type: "post",
                async: false,
                url: "<%=path%>/menu/Tree",
                success: function (data) {
                    console.log(data);

                    tree = data;

                },
                error: function (data) {
                    console.log(data);
                }

            })
            return tree;
        }

        $(function () {
            $('#tree').treeview({
                data: getTree(),
                showCheckbox: true,
                backColor: " orange",
                borderColor: "red",//边框颜色
                color: "green",//字体
                //data当前选中的节点

                onNodeSelected: function (event, data) {
                    // console.log(event);
                    // console.log(data);
                    // location.href=data.url;
                    if (data.url != null && data.url != "") {
                        $.addtabs.add({
                            // 添加标签也
                            title: data.text,
                            url: "<%=path%>" + data.url,
                            id: data.id,


                        })
                    }

                }

            });

        })


    </script>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-lg-3">
            <div id="tree"></div>
        </div>
        <div class="col-lg-9">
            <ul class="nav nav-tabs" id="mtTab"></ul>
            <%--            ul 代表标题 div 代表内容/--%>
            <div class="tab-content"></div>
        </div>
    </div>
</div>
</body>
</html>
